package com.wlyuan.open.infrastructure.converter;

import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.core.marker.MappingStatus;
import com.wlyuan.open.dao.entity.PushTaskDO;
import com.wlyuan.open.domain.PushTask;
import com.wlyuan.open.domain.PushTaskId;
import com.wlyuan.open.domain.mappings.MappingPush;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author
 *
 */
public class PushTaskConverter {
    @Mapper(imports = {
            PushTaskId.class,
    }, uses = {
            MappingStatus.class,
            MappingIds.class,
            MappingPush.class
    })
    public interface Converter {

        PushTaskDO convert(PushTask pushTask);

        PushTask convert(PushTaskDO pushTaskDO);

        List<PushTask> convert(List<PushTaskDO> source);
    }

    private static final Converter CONVERTER = Mappers.getMapper(Converter.class);

    public static PushTaskDO convert(PushTask pushTask){
        return CONVERTER.convert(pushTask);
    }

    public static PushTask convert(PushTaskDO pushTaskDO){
        return CONVERTER.convert(pushTaskDO);
    }

    public static List<PushTask> convert(List<PushTaskDO> source){
        return CONVERTER.convert(source);
    }
}
